package ru.len.cafe.ejb.dao;

import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

import ru.len.cafe.entity.model.Ingredient;

@Stateless
public class IngredientDao {

    @PersistenceContext(unitName= "LenCafePU")
    EntityManager em;
    
    /**
     * Add ingredient to the database
     * @param table
     */
    public void createIngredient(Ingredient ingredient){
	em.persist(ingredient);
    }
    
    /**
     * Deletes ingredient from the database
     * @param table
     */
    public void deleteIngredient(Ingredient ingredient){
	em.remove(ingredient);
    }
    
    /**
     * Updates existing ingredient
     * @param table
     */
    public void updateIngredient(Ingredient ingredient){
	em.refresh(ingredient);
    }
    
}
